#ifndef INDEX_H
#define INDEX_H
#include "common.h"

#define SITES_FORMATTED "sites_formatted"
#define ATTR_DIR "attr"
#define PATH_DIR "path"
#define PATH_MAP ".map"
#define INDEX_DIR "index"

struct site {
	unsigned int siteId;
	char ip_addr[MAXADDR];
	unsigned short int port;
	char username[MAXNAME];
	char password[MAXNAME];
};

struct attr {
	unsigned int attrId;
	char datetime[MAXDATETIME];
	unsigned long long fileSize;
	unsigned int offset;
	unsigned int length;
};

struct path {
	unsigned int pathId;
	unsigned int offset;
	unsigned int length;
};

struct index {
	unsigned int siteId;
	unsigned int pathId;
	unsigned int attrId;
};

struct index2 {
	unsigned int count;
	struct index idx;

bool operator<(const struct index2 &other);
};

char *filename_position(char *buf);
int isDosLine(char *buf);
int isUnixLine(char *buf);
int setDosLine(struct attr *pAttr,int attrId,char *buf);
int setUnixLine(struct attr *pAttr,int attrId,char *buf);
void month_aton(char *tmp,char array[2]);

int set_attr(struct attr *pAttr,int attrId,char *buf);

#endif
